package routes

import (
	"github.com/goravel/framework/contracts/route"
	"github.com/goravel/framework/facades"
	"goravel/app/http/controllers"
	"goravel/app/http/middleware"
)

func Api() {
	//后台管理
	authContr := controllers.NewAuthController()
	facades.Route().Post("/api/admin/login", authContr.AdminLogin)

	//验证码
	captchaCtrl := controllers.NewCaptchaController()
	facades.Route().Get("/api/admin/captcha", captchaCtrl.GetCaptcha)
	facades.Route().Post("/api/admin/validate", captchaCtrl.ValidateCaptcha)
	facades.Route().Middleware(middleware.Jwt()).Prefix("/api/admin").Group(func(router route.Router) {
		uploadController := controllers.NewUploadController()
		router.Post("upload", uploadController.Upload)
		router.Post("wangeditor", uploadController.Wangeditor)
		userCtrl := controllers.NewUserController()
		router.Get("user", userCtrl.Index)
		router.Post("user", userCtrl.Store)
		router.Delete("user/{id}", userCtrl.Destroy)
		router.Put("user/{id}", userCtrl.Update)
		router.Get("user/list", userCtrl.List)
		router.Get("account/profile", userCtrl.Profile)
		router.Post("user/setrole", userCtrl.SetRole)
		router.Post("user/hasrole", userCtrl.HasRole)
		router.Get("user/employee", userCtrl.EmployeeList)
		//	服务监控
		monitorCtrl := controllers.NewMonitorController()
		router.Get("monitor", monitorCtrl.Index)
		syslogCtrl := controllers.NewSyslogController()
		router.Get("syslog", syslogCtrl.Index)

		//	任务修改
		cornCtrl := controllers.NewCornController()
		router.Get("corn", cornCtrl.Index)
		/**
		角色*/
		roleCtrl := controllers.NewRoleController()
		router.Get("role", roleCtrl.Index)
		authCtrl := controllers.NewAuthController()
		router.Get("logout", authCtrl.Logout)
		//菜单
		menuCtrl := controllers.NewMenuController()
		router.Get("menu", menuCtrl.Index)
		router.Get("menu/init", menuCtrl.Init)
		router.Get("menu/tree", menuCtrl.GetTree)
		//权限
		router.Get("permission/init", menuCtrl.InitPermissions)
		router.Get("permission", menuCtrl.GetPermissions)

		//汽车类型
		carCtrl := controllers.NewCarController()
		router.Resource("car", carCtrl)
		//服务项目
		serviceCtrl := controllers.NewServiceController()
		router.Resource("service", serviceCtrl)
		router.Get("service/init", serviceCtrl.Init)
		router.Post("service/option", serviceCtrl.Option)

		//工时分类
		kindCtrl := controllers.NewKindController()
		router.Get("kind/list", kindCtrl.List)
		router.Get("kind/tree", kindCtrl.Tree)
		router.Post("kind", kindCtrl.Store)
		router.Put("kind/{id}", kindCtrl.Update)
		router.Delete("kind/{id}", kindCtrl.Destroy)
		router.Post("kind/option", kindCtrl.Option)

		//工时
		manhourCtrl := controllers.NewManhourController()
		router.Get("manhour", manhourCtrl.Index)
		router.Post("manhour", manhourCtrl.Store)
		router.Put("manhour/{id}", manhourCtrl.Update)
		router.Delete("manhour/{id}", manhourCtrl.Destroy)
		router.Get("manhour/init", manhourCtrl.Init)
		router.Post("manhour/query", manhourCtrl.Query)

		//客户报修-报修单
		repairCtrl := controllers.NewRepairController()
		router.Resource("repair", repairCtrl)
		router.Get("repair/online", repairCtrl.Online)

		//工单流程选项
		process_stateCtrl := controllers.NewProcessStateController()
		router.Post("process_state/list", process_stateCtrl.List)
		//工单-维修单
		ticketCtrl := controllers.NewTicketController()
		//开始工单
		router.Post("ticket/start", ticketCtrl.Start)
		router.Get("ticket/todo", ticketCtrl.ToDo)
		router.Get("ticket/abtodo", ticketCtrl.AbToDo)
		router.Post("ticket/sign", ticketCtrl.Sign)
		router.Post("ticket/pass", ticketCtrl.Pass)
		router.Post("ticket/confirm", ticketCtrl.Confirm)
		router.Get("ticket/{id}", ticketCtrl.Show)
		router.Post("ticket/abnormal", ticketCtrl.AbNormal)
		router.Get("ticket/{id}/abnormaldetail", ticketCtrl.AbNormalDetail)

		//工时记录
		recordCtrl := controllers.NewRecordController()
		router.Get("record", recordCtrl.Index)
		//工时统计

		router.Get("record/statistics/year", recordCtrl.YearStatistics)
		router.Get("record/statistics/month", recordCtrl.MonthStatistics)
		//年报
		router.Get("record/statistics/annual", recordCtrl.AnnualStatistics)
		//工位
		parkingCtrl := controllers.NewParkingController()
		router.Resource("parking", parkingCtrl)
		router.Get("parking/option", parkingCtrl.Option)
		router.Get("parking/online", parkingCtrl.Online)

		//工位使用情况
		parkingstateCtrl := controllers.NewParkingStateController()
		router.Get("parkingstate", parkingstateCtrl.Index)
		router.Get("parkingstate/{id}/state", parkingstateCtrl.State)
		dashboradCtrl := controllers.NewDashboardController()
		router.Post("dashboard/home", dashboradCtrl.Home)
		router.Post("dashboard/employee", dashboradCtrl.Employee)

	})
	//发送验证码
	smsController := controllers.SmsController{}
	facades.Route().Post("api/mini/auth/validcode", smsController.ValidCode)
	//小程序登录
	facades.Route().Post("api/mini/auth/login", authContr.MiniLogin)

	facades.Route().Middleware(middleware.Jwt()).Prefix("api/mini").Group(func(router route.Router) {
		repairCtrl := controllers.NewRepairController()
		router.Post("repair", repairCtrl.MiniStore)
		router.Get("repair", repairCtrl.MiniIndex)
		router.Get("repair/history", repairCtrl.MiniHistoryIndex)
		router.Get("repair/{id}", repairCtrl.MiniShow)

		uploadCtrl := controllers.NewUploadController()
		router.Post("upload", uploadCtrl.Upload)

		ticketCtrl := controllers.TicketController{}
		router.Post("ticket/sign", ticketCtrl.MiniSign)
		router.Get("ticket/{id}", ticketCtrl.MiniShow)
		router.Post("ticket/start", ticketCtrl.MiniStart)
		router.Post("ticket/pass", ticketCtrl.MiniPass)

		//工时查询

		manhourCtrl := controllers.NewManhourController()
		router.Post("manhour/query", manhourCtrl.MiniQuery)

		authCtrl := controllers.NewAuthController()
		router.Get("auth/logout", authCtrl.MiniLogout)
		//重置密码
		router.Post("auth/reset", authCtrl.MiniReset)

		//汽车
		carCtrl := controllers.NewCarController()
		router.Get("car/list", carCtrl.MiniList)
		optCtrl := controllers.NewMiniController()
		router.Get("opt", optCtrl.MiniOption)
		router.Post("opt/user", optCtrl.MiniUserOption)
		router.Post("opt/service", optCtrl.MiniServiceOption)
		//改异常工单
		router.Post("ticket/abnormal", ticketCtrl.MiniAbNormal)

		miniCtrl := controllers.NewMiniController()
		//异常工单选择员工，
		router.Post("opt/except_user", miniCtrl.MiniUserExceptOption)
		//异常工单选择维修项目
		router.Post("opt/except_service", miniCtrl.MiniServiceExceptOption)
		//小程序首页数据
		router.Get("repair/info", miniCtrl.MiniRepairInfo)
		//异常工单审批
		router.Post("ticket/confirm", ticketCtrl.MiniConfirm)

		//工时统计
		recordCtrl := controllers.NewRecordController()
		router.Get("record/statistics/year", recordCtrl.MiniYearStatistics)
		router.Get("record/statistics/month", recordCtrl.MiniMonthStatistics)
		//年报
		router.Get("record/statistics/annual", recordCtrl.MiniAnnualStatistics)

		suggestionCtrl := controllers.NewSuggestionController()
		router.Resource("suggestion", suggestionCtrl)

	})
}
